package org.mixed.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.mixed.config.MixProperties;
import org.mixed.core.enums.Options;
import org.mixed.core.plugin.Plugin;
import org.mixed.core.utils.ClassScanner;
import org.mixed.core.domain.ApiResponse;
import org.mixed.core.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.*;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@RestController
@RequestMapping("${mix.prefix:/mix/web}")
@Slf4j
public class MixApiController {
    @Autowired
    private MixProperties properties;

    private String allClasses;

    @PostMapping("/login")
    public ApiResponse<Boolean> login(String username, String password, HttpServletRequest request, HttpServletResponse response) {
//        if (configuration.getAuthorizationInterceptor().requireLogin()) {
//            if (StringUtils.isBlank(username) && StringUtils.isBlank(password)) {
//                try {
//                    configuration.getAuthorizationInterceptor().getUserByToken(request.getHeader(Constants.MAGIC_TOKEN_HEADER));
//                } catch (MagicLoginException ignored) {
//                    return new ApiResponse<>(false);
//                }
//            } else {
//                MagicUser user = configuration.getAuthorizationInterceptor().login(username, password);
//                response.setHeader(Constants.MAGIC_TOKEN_HEADER, user.getToken());
//                response.setHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, Constants.MAGIC_TOKEN_HEADER);
//            }
//        }
        return ApiResponse.success(true);
    }

    @PostMapping("/user")
    public ApiResponse<SysUser> user(HttpServletRequest request) {
//        if (configuration.getAuthorizationInterceptor().requireLogin()) {
//            try {
//                return new ApiResponse<>(configuration.getAuthorizationInterceptor().getUserByToken(request.getHeader(Constants.MAGIC_TOKEN_HEADER)));
//            } catch (MagicLoginException ignored) {
//
//            }
//        }
        return ApiResponse.success(SysUser.guest());
    }

    @GetMapping("/options")
    public ApiResponse<List<List<String>>> options() {
        return ApiResponse.success(Stream.of(Options.values())
                .map(item -> Arrays.asList(item.getValue(), item.getName(), item.getDefaultValue()))
                .collect(Collectors.toList()));
    }

    @GetMapping(value = "/config-js")
    public void configJs(HttpServletResponse response) throws IOException {
        response.setContentType("application/javascript");
        response.setCharacterEncoding("UTF-8");
        byte[] bytes = "var MAGIC_EDITOR_CONFIG = {}".getBytes();
        if (properties.getEditorConfig() != null) {
            File file = ResourceUtils.getFile(properties.getEditorConfig());
            bytes = Files.readAllBytes(Paths.get(file.toURI()));
        }
        try (OutputStream stream = response.getOutputStream()) {
            stream.write(bytes);
            stream.flush();
        }
    }

    @GetMapping("/config.json")
    public MixProperties readConfig() {
        return properties;
    }

    @GetMapping(value = "/classes.txt", produces = "text/plain")
    private String getAllClasses() {
        if (allClasses == null) {
            try {
                allClasses = ClassScanner.compress(ClassScanner.scan());
            } catch (URISyntaxException | IOException e) {
                allClasses = "";
            }
        }
        return allClasses;
    }

    @PostMapping("/classes")
    public ApiResponse<Object> classes() throws JsonProcessingException {
//        Map<String, ScriptClass> classMap = MagicScriptEngine.getScriptClassMap();
//        classMap.putAll(MixResourceLoader.getModules());
//        Map<String, Object> values = new HashMap<>();
//        values.put("classes", new ArrayList<>());
//        values.put("extensions", new ArrayList<>());
//        values.put("functions", new ArrayList<>());
        ObjectMapper objectMapper = new ObjectMapper();
        return ApiResponse.success(objectMapper.readValue("""
                {
                        "extensions": {
                            "java.util.Iterator": {
                                "className": null,
                                "methods": [
                                    {
                                        "name": "asBean",
                                        "returnType": "java.lang.Object",
                                        "comment": "将集合转为JavaBean",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "target",
                                                "type": "java.lang.Class",
                                                "varArgs": false,
                                                "comment": "目标类型"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "findNotNull",
                                        "returnType": "java.lang.Object",
                                        "comment": "找到集合中第一个不为null的元素",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "getLength",
                                        "returnType": "int",
                                        "comment": "返回集合或数组的长度",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "size",
                                        "returnType": "int",
                                        "comment": "返回集合或数组的长度",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "join",
                                        "returnType": "java.util.List",
                                        "comment": "将两个集合关联起来",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "target",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": "另一个集合"
                                            },
                                            {
                                                "name": "condition",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "关联条件，如:`(left,right)=>left.xxx = right.xxx`"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "sum",
                                        "returnType": "java.lang.Number",
                                        "comment": "对集合进行累加操作",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "concat",
                                        "returnType": "java.lang.Object",
                                        "comment": "合并多个集合, 返回新的集合",
                                        "origin": true,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "target",
                                                "type": "Object[]",
                                                "varArgs": true,
                                                "comment": "集合"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "push",
                                        "returnType": "java.lang.Object",
                                        "comment": "向集合中添加元素",
                                        "origin": true,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "item",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": "要添加的元素"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "arrayLikeToList",
                                        "returnType": "java.util.List",
                                        "comment": "将对象转为List",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "join",
                                        "returnType": "java.util.List",
                                        "comment": "将两个集合关联并转换",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "target",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": "另一个集合"
                                            },
                                            {
                                                "name": "condition",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "关联条件，如:`(left,right)=>left.xxx == right.xxx`"
                                            },
                                            {
                                                "name": "mapping",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "映射函数，如:`(left,right)=>{xxx : left.xxx, yyy : right.yyy}`"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "sort",
                                        "returnType": "java.lang.Object",
                                        "comment": "将集合进行排序，并返回新集合",
                                        "origin": true,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "function",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "排序函数，如从大到小`(a,b)=>a-b`"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "reserve",
                                        "returnType": "java.lang.Object",
                                        "comment": "将集合进行反转操作",
                                        "origin": true,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "join",
                                        "returnType": "java.lang.String",
                                        "comment": "将集合使用`,`拼接起来",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "last",
                                        "returnType": "java.lang.Object",
                                        "comment": "返回集合中的最后一个元素",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "find",
                                        "returnType": "java.lang.Object",
                                        "comment": "查找元素",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "function",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "匹配条件，如`(item)=>item.xxx == 1`"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "toMap",
                                        "returnType": "java.util.Map",
                                        "comment": "集合转为Map",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "mappingKey",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "key值"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "shuffle",
                                        "returnType": "java.lang.Object",
                                        "comment": "将集合的顺序打乱",
                                        "origin": true,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "toMap",
                                        "returnType": "java.util.Map",
                                        "comment": "集合转为Map",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "mappingKey",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "key值"
                                            },
                                            {
                                                "name": "mappingValue",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "value值"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "distinct",
                                        "returnType": "java.lang.Object",
                                        "comment": "集合去重",
                                        "origin": true,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "condition",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "去重转换器，如根据id去重 `item=>item.id`"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "max",
                                        "returnType": "java.lang.Object",
                                        "comment": "取出集合最大值，如果找不到返回`null`",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "min",
                                        "returnType": "java.lang.Object",
                                        "comment": "取出集合最小值，如果找不到返回`null`",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "join",
                                        "returnType": "java.lang.String",
                                        "comment": "将集合使用连接符拼接起来",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "separator",
                                                "type": "java.lang.String",
                                                "varArgs": false,
                                                "comment": "拼接符，如`,`"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "asBean",
                                        "returnType": "java.lang.Object",
                                        "comment": "将集合转为JavaBean",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "target",
                                                "type": "java.lang.Class",
                                                "varArgs": false,
                                                "comment": "目标类型"
                                            },
                                            {
                                                "name": "isArray",
                                                "type": "boolean",
                                                "varArgs": false,
                                                "comment": "是否是数组"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "limit",
                                        "returnType": "java.lang.Object",
                                        "comment": "限制集合数量",
                                        "origin": true,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "value",
                                                "type": "int",
                                                "varArgs": false,
                                                "comment": "跳过的数量"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "group",
                                        "returnType": "java.util.Map",
                                        "comment": "对集合进行分组并转换",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "condition",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "分组条件，如`item=>item.xxx + '_' + item.yyy`"
                                            },
                                            {
                                                "name": "mapping",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "转换函数，如分组求和`(list)=>list.sum()`"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "first",
                                        "returnType": "java.lang.Object",
                                        "comment": "返回集合中的第一个元素",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "avg",
                                        "returnType": "java.lang.Double",
                                        "comment": "取出集合平均值，如果无法计算返回`null`",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "every",
                                        "returnType": "boolean",
                                        "comment": "判断集合是否都满足条件",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "condition",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "判断条件"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "filter",
                                        "returnType": "java.lang.Object",
                                        "comment": "将集合进行过滤，并返回新集合",
                                        "origin": true,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "function",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "过滤条件，如`(item)=>item.xxx == 1`"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "map",
                                        "returnType": "java.lang.Object",
                                        "comment": "将集合进行转换，并返回新集合",
                                        "origin": true,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "function",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "转换函数，如提取属性`(item)=>item.xxx`"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "skip",
                                        "returnType": "java.lang.Object",
                                        "comment": "截取集合",
                                        "origin": true,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "value",
                                                "type": "int",
                                                "varArgs": false,
                                                "comment": "跳过的数量"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "distinct",
                                        "returnType": "java.lang.Object",
                                        "comment": "集合去重",
                                        "origin": true,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "group",
                                        "returnType": "java.util.Map",
                                        "comment": "对集合进行分组",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "condition",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "分组条件，如`item=>item.xxx + '_' + item.yyy`"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "some",
                                        "returnType": "boolean",
                                        "comment": "判断集合中是否至少有一个元素满足条件",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "condition",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "判断条件"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "reduce",
                                        "returnType": "java.lang.Object",
                                        "comment": "循环集合通过给定的计算函数返回一个新值",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "reduceFunction",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "处理函数，如累加计算：`(val,item)=>val + item`"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "findIndex",
                                        "returnType": "int",
                                        "comment": "查找元素索引",
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "function",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "匹配条件，如`(item)=>item.xxx == 1`"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "each",
                                        "returnType": "java.lang.Object",
                                        "comment": "将集合进行循环操作，并返回新集合",
                                        "origin": true,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.Object",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "function",
                                                "type": "java.util.function.Function",
                                                "varArgs": false,
                                                "comment": "循环函数，如循环添加属性`(item)=>{item.xxx = 'newVal'}`"
                                            }
                                        ]
                                    }
                                ],
                                "attributes": [],
                                "superClass": null,
                                "interfaces": [],
                                "enums": null,
                                "module": false
                            }
                        },
                        "functions": [
                            {
                                "name": "min",
                                "returnType": "java.lang.Object",
                                "comment": "聚合函数-min",
                                "origin": false,
                                "deprecated": false,
                                "parameters": [
                                    {
                                        "name": "value",
                                        "type": "java.lang.Object",
                                        "varArgs": false,
                                        "comment": "集合"
                                    }
                                ]
                            }
                        ],
                        "classes": {
                            "magic": {
                                "className": "org.ssssssss.magicapi.core.service.impl.DefaultMagicAPIService",
                                "methods": [
                                    {
                                        "name": "download",
                                        "returnType": "void",
                                        "comment": null,
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.String",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "arg1",
                                                "type": "java.util.List",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "arg2",
                                                "type": "java.io.OutputStream",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "upload",
                                        "returnType": "boolean",
                                        "comment": null,
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.io.InputStream",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "arg1",
                                                "type": "java.lang.String",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "invoke",
                                        "returnType": "java.lang.Object",
                                        "comment": null,
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.String",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "arg1",
                                                "type": "java.util.Map",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "push",
                                        "returnType": "org.ssssssss.magicapi.core.model.ApiResponse",
                                        "comment": null,
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.String",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "arg1",
                                                "type": "java.lang.String",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "arg2",
                                                "type": "java.lang.String",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "arg3",
                                                "type": "java.util.List",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "call",
                                        "returnType": "java.lang.Object",
                                        "comment": null,
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.String",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "arg1",
                                                "type": "java.lang.String",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "arg2",
                                                "type": "java.util.Map",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "processNotify",
                                        "returnType": "boolean",
                                        "comment": null,
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "org.ssssssss.magicapi.core.model.MagicNotify",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    },
                                    {
                                        "name": "execute",
                                        "returnType": "java.lang.Object",
                                        "comment": null,
                                        "origin": false,
                                        "deprecated": false,
                                        "parameters": [
                                            {
                                                "name": "arg0",
                                                "type": "java.lang.String",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "arg1",
                                                "type": "java.lang.String",
                                                "varArgs": false,
                                                "comment": null
                                            },
                                            {
                                                "name": "arg2",
                                                "type": "java.util.Map",
                                                "varArgs": false,
                                                "comment": null
                                            }
                                        ]
                                    }
                                ],
                                "attributes": [],
                                "superClass": "java.lang.Object",
                                "interfaces": [],
                                "enums": null,
                                "module": true
                            }
                        }
                    }
                """, Object.class));
    }

    @GetMapping("/plugins")
    public ApiResponse<List<Plugin>> plugins() {
        return ApiResponse.success(new ArrayList<>());
    }
}
